import {
	defineConfig,
	loadEnv
} from 'vite'
import vue from '@vitejs/plugin-vue'
//path对象用来读取路径变量
const path = require('path');

// https://vitejs.dev/config/
export default ({
	command,
	mode
}) => {
	return defineConfig({
		//配置插件
		plugins: [vue()],
		//配置别名
		resolve: {
			alias: {
				'@': path.resolve(__dirname, './src'),
			}
		},
		server: {
			//项目启动端口
			port: loadEnv(mode, process.cwd()).VITE_PORT,
			//是否自动在浏览器打开
			open: true,
			//是否开启https
			https: false
			/* ,
			//代理
			proxy: {
				'/api': {
					target: 'http://localhost:9232',
					changeOrigin: true
				}
			} */
		}
	})
}
